package com.youngjun.gateway.controller;

import com.youngjun.gateway.service.SwaggerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import springfox.documentation.annotations.ApiIgnore;
import springfox.documentation.swagger.web.*;

import java.util.List;

/**
 * swagger聚合接口，三个接口都是swagger-ui.html需要访问的接口
 * @author virgojun
 */
@RestController
@ApiIgnore
public class SwaggerResourceController {

    @Autowired
    private SwaggerService swaggerService;

    @RequestMapping(value = "/swagger-resources")
    public ResponseEntity<List<SwaggerResource>> swaggerResources() {
        return new ResponseEntity<>(swaggerService.get(), HttpStatus.OK);
    }

    @RequestMapping(value = "/swagger-resources/configuration/security")
    public ResponseEntity<SecurityConfiguration> securityConfiguration() {
        return new ResponseEntity<>(SecurityConfigurationBuilder.builder().build(), HttpStatus.OK);
    }

    @RequestMapping(value = "/swagger-resources/configuration/ui")
    public ResponseEntity<UiConfiguration> uiConfiguration() {
        return new ResponseEntity<>(UiConfigurationBuilder.builder().build(), HttpStatus.OK);
    }

    @RequestMapping("/")
    public ResponseEntity<List<SwaggerResource>> swaggerResourcesN() {
        return new ResponseEntity<>(swaggerService.get(), HttpStatus.OK);
    }

    @RequestMapping("/csrf")
    public ResponseEntity<List<SwaggerResource>> swaggerResourcesCsrf() {
        return new ResponseEntity<>(swaggerService.get(), HttpStatus.OK);
    }

}